package com.example.test;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.google.android.material.bottomnavigation.BottomNavigationView;

public class HomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home);

        BottomNavigationView bottomNav = findViewById(R.id.bottom_navigation);
        Button addButton = findViewById(R.id.fab_add);
        bottomNav.setOnItemSelectedListener(item -> {
            int itemId = item.getItemId();
            if (itemId == R.id.navigation_home) {
                startActivity(new Intent(HomeActivity.this, HomeActivity.class));
                return true;
            } else if (itemId == R.id.navigation_focus) {
                startActivity(new Intent(HomeActivity.this, FocusActivity.class));
                return true;
            } else if (itemId == R.id.navigation_mine) {
                startActivity(new Intent(HomeActivity.this, MineActivity.class));
                return true;
            }
            return false;
        });

        addButton.setOnClickListener(view -> {
            // 创建Intent来启动SecondActivity
            Intent intent = new Intent(HomeActivity.this, PlanActivity.class);
            startActivity(intent);
        });
    }
}
